﻿Imports System.Data.OleDb
Imports System.Data

Partial Class Members_AddMemebers
    Inherits System.Web.UI.Page

    Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click
        Dim myGuid As New System.Guid
        Dim newFileName = myGuid.ToString() + ".jpg"

        If f_picture.HasFile Then
            Dim picLocationOnServerHardDisk = Request.MapPath("../images") & "/" & newFileName
            f_picture.SaveAs(picLocationOnServerHardDisk)
        End If

        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("myFirstDatabase").ConnectionString)
        Dim SqlString As String = "Insert into Members(FirstName,LastName,Address,Email,skype,About,Mem_Images,Role) Values (@f1,@f2,@f3,@f4,@f5,@f6,@f7,@f8)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", tbFirstName.Text)
        cmd.Parameters.AddWithValue("@f2", tbLastName.Text)
        cmd.Parameters.AddWithValue("@f3", tbAddress.Text)
        cmd.Parameters.AddWithValue("@f4", tbEmail.Text)
        cmd.Parameters.AddWithValue("@f5", tbskype.Text)
        cmd.Parameters.AddWithValue("@f5", tbAbout.Text)
        cmd.Parameters.AddWithValue("@f6", "../images/" & newFileName)
        cmd.Parameters.AddWithValue("@f7", tbRole.Text)
        oleDbConn.Open()
        cmd.ExecuteNonQuery()
        Response.Redirect("~/Confirmation.aspx")
    End Sub
End Class
